<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Ajax</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>

<body>
    <button>get</button>
    <button>post</button>
    <button>通用</button>
    <script>
        $('button').eq(0).click(function() {
            $.get('http://127.0.0.1:8000/jquery', {
                a: 100,
                b: 200
            }, function(data) {
                console.log(data);
            }, 'json')
        });
        $('button').eq(1).click(function() {
            $.post('http://127.0.0.1:8000/jquery', {
                a: 100,
                b: 200
            }, function(data) {
                console.log(data);
            }, 'json')
        });
        $('button').eq(2).click(function() {
            $.ajax({
                url: 'http://127.0.0.1:8000/jquery',
                data: {
                    a: 100,
                    b: 200
                },
                type: 'GET',
                dataType: 'json',
                success: function(data) {
                    console.log(data);
                },
                timeout: 3000,
                error: function() {
                    console.log('出错了！');
                },
                headers: {
                    c: 500,
                    d: 600
                }
            })
        })
    </script>
</body>

</html>